
exports.ARRAYHOURS = ["0000","0030","0100", "0130","0200", "0230", "0300", "0330", "0400", "0430", "0500", "0530", "0600","0630","0700","0730","0800","0830","0900","0930","1000","1030","1100","1130","1200","1230","1300","1330","1400","1430","1500","1530","1600","1630","1700","1730","1800","1830","1900","1930","2000","2030","2100","2130","2200","2230","2300","2330"];

exports.arrayToCSV = function arrayToCSV(tableauData){
	var lineCSV ="";
	for(var i=0, length=tableauData.length; i<length; i++){
		for(var j=0; j < tableauData[i].length; j++){
			lineCSV += tableauData[i][j]+";";
		}
		lineCSV += "\n";
	}
	
	return lineCSV;
}

//Retourne un tableau contenant les rendez-vous pour la demi-heure donnée pour chaque jour de la semaine

exports.getRDVAllDays = function getRDVAllDays(halfHour, semaineObj){

	var tabToReturn = [];
	
	for(var i = 0, length=semaineObj.listePlanning.length; i<length; i++){
		var rdv = semaineObj.listePlanning[i].listeRendezVous[halfHour];
		if(rdv != null){
			tabToReturn.push(rdv.descCSV + "(" + rdv.lieu + ")");
		}
		else{
			tabToReturn.push("vide");
		}
	}
	return tabToReturn;
}

exports.unfold = function unfold(icalString){

	for(var i = 0, length=icalString.length; i<length; i++){
		if(icalString.charAt(i) == "\n"){
			if(icalString.charAt(i+1) == " " || icalString.charAt(i+1) == "\t"){
				icalString = icalString.slice(0, i) + icalString.slice(i+2);
			}
		}
	}
	return icalString;
}
